#include "messages.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#define NUMBER_MESSAGES 128

char * messages[NUMBER_MESSAGES];
size_t message_count = 0;

void post_message( const char * message )
{
    if ( message_count == NUMBER_MESSAGES )
        return;

    messages[message_count] = malloc( sizeof(char) * strlen(message) + 1 );
    strcpy( messages[message_count], message );
    ++message_count;
}

void print_messages()
{
    for( size_t i = 0; i < message_count; i++ )
    {
        printf( "%s", messages[i] );
        free( messages[i] );
    }

    message_count = 0;
}
